+2006-09-10 Kevin Cozens <kcozens@cvs.gnome.org>
+
+ * babl/babl-classes.h
+ * babl/babl-conversion.c
+ * babl/babl-fish-path.c
+ * babl/babl-fish-stats.c
+ * babl/babl-internal.c: Tick times are in usecs not msecs. Use longs
+ to hold tick values.
+
+ * babl/babl-util.h:
+ * babl/babl-util.c (babl_ticks): Fixed calculation of time (usecs
+ not msecs). Changed declaration to return a long not unsigned int.
+
2006-09-09 Øyvind Kolås <pippin@gimp.org>
* extensions/Makefile.am: moved -fPIC from LD_FLAGS to CFLAGS.
BablInstance instance;
union Babl *source;
union Babl *destination;
- int cost;
+ long cost;
double error;
union
{
BablModel *model;
int bytes_per_pixel;
int planar;
- double loss; /*< average relative error when converting
+ double loss; /*< average relative error when converting
from and to RGBA double */
} BablFormat;
/* instrumentation */
int processings; /* number of times the fish has been used */
long pixels; /* number of pixels translates */
- long msecs; /* msecs spent within this fish */
+ long usecs; /* usecs spent within this fish */
} BablFish;
BablConversion *conversion[BABL_HARD_MAX_PATH_LENGTH];
} BablFishPath;
-/* BablFishReference
+/* BablFishReference
*
* A BablFishReference is not intended to be fast, thus the algorithm
* encoded can use a multi stage approach, based on the knowledge babl
{
BablInstance instance; /* path to .so / .dll is stored in instance name */
void *dl_handle;
- void (*destroy) (void);
+ void (*destroy) (void);
} BablExtension;
typedef union
#include <stdarg.h>
#include <math.h>
-static int
+static int
each_babl_conversion_destroy (Babl *babl,
void *data)
{
Babl *source,
Babl *destination,
BablFuncLinear linear,
- BablFuncPlane plane,
+ BablFuncPlane plane,
BablFuncPlanar planar)
{
Babl *babl = NULL;
babl->conversion.source = (union Babl*)source;
babl->conversion.destination = (union Babl*)destination;
babl->conversion.error = -1.0;
- babl->conversion.cost = 69;
+ babl->conversion.cost = 69L;
babl->conversion.pixels = 0;
babl->conversion.processings = 0;
}
babl_conversion_new (
src_format,
- dst_format,
+ dst_format,
"linear", linear,
NULL);
babl->conversion.error = 0.0;
assert (BABL_IS_BABL(source));
assert (BABL_IS_BABL(destination));
-
-
+
+
while (arg)
{
-
+
if (!strcmp (arg, "id"))
{
id = va_arg (varg, int);
}
-
+
else if (!strcmp (arg, "linear"))
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
linear = va_arg (varg, BablFuncLinear);
}
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
plane = va_arg (varg, BablFuncPlane);
}
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
planar = va_arg (varg, BablFuncPlanar);
}
arg = va_arg (varg, char *);
}
-
+
va_end (varg);
assert (source);
babl = conversion_new (create_name (source, destination, type),
id, source, destination, linear, plane, planar);
- {
+ {
Babl *ret = babl_db_insert (db, babl);
if (ret!=babl)
babl_free (babl);
#ifdef USE_ALLOCA
void **src_data = alloca (sizeof (void*) * source->components);
void **dst_data = alloca (sizeof (void*) * destination->components);
-#else
+#else
void *src_data[BABL_MAX_COMPONENTS];
void *dst_data[BABL_MAX_COMPONENTS];
#endif
memcpy (src_data, source->data, sizeof (void*) * source->components);
memcpy (dst_data, destination->data, sizeof (void*) * destination->components);
-
+
return conversion->function.planar (source->components,
src_data,
source->pitch,
if (BABL_IS_BABL(source))
{
BablImage *img;
-
+
img = (BablImage*)source;
src_data = img->data[0];
src_pitch = img->pitch[0];
if (BABL_IS_BABL(destination))
{
BablImage *img = (BablImage*)destination;
-
+
dst_data = img->data[0];
dst_pitch = img->pitch[0];
}
babl_assert (BABL_IS_BABL (destination));
babl_conversion_planar_process ( conversion,
- (BablImage*) source,
+ (BablImage*) source,
(BablImage*) destination,
n);
break;
case BABL_CONVERSION_LINEAR:
- /* the assertions relied on a babl_malloc structure
+ /* the assertions relied on a babl_malloc structure
*
* babl_assert (!BABL_IS_BABL (source));
babl_assert (!BABL_IS_BABL (destination));*/
babl_conversion_linear_process (conversion,
- source,
+ source,
destination,
n);
break;
{
double *test;
int i;
-
+
srandom (20050728);
test = babl_malloc (sizeof (double) * test_pixels * 4);
babl_conversion_cost (BablConversion *conversion)
{
if (!conversion)
- return 100000000.0;
+ return 100000000L;
if (conversion->error==-1.0)
babl_conversion_error (conversion);
return conversion->cost;
}
-
+
double
babl_conversion_error (BablConversion *conversion)
{
NULL);
double error = 0.0;
- unsigned int ticks_start = 0;
- unsigned int ticks_end = 0;
-
- double *test;
+ long ticks_start = 0;
+ long ticks_end = 0;
+
+ double *test;
void *source;
void *destination;
double *destination_rgba_double;
{
return conversion->error;
}
-
+
test=test_create ();
ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
-
+
babl_process (fish_rgba_to_source,
test, source, test_pixels);
fish_reference->fish.pixels -= test_pixels;
fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
-
+
babl_free (source);
babl_free (destination);
babl_free (destination_rgba_double);
format.from)
babl_list_each (
- (void **)
+ (void **)
BABL(temp_chain[temp_conversions-1]->destination)->
format.from,
chain_gen_each,
if ((BABL(babl->conversion.destination) == c->to) )
{
/* a candidate path has been found */
-
+
double temp_cost = 0.0;
double temp_error = 1.0;
int i;
temp_error *= (1.0+babl_conversion_error (c->temp_chain[i]));
temp_cost += babl_conversion_cost (c->temp_chain[i]);
}
-
+
if (temp_cost < *c->best_cost &&
temp_error - 1.0 <= legal_error() && /* this check before the next; which does a more accurate
measurement of the error */
- (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
+ (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
)
{
int i;
babl->fish.processings = 0;
babl->fish.pixels = 0;
- babl->fish.msecs = 0;
+ babl->fish.usecs = 0;
babl->fish.error = 200000;
babl->fish_path.cost = 200000;
babl_assert (source->class_type == BABL_FORMAT);
babl_assert (destination->class_type == BABL_FORMAT);
-
+
get_conversion_chain (source,
destination,
&babl->fish_path.cost,
(BablConversion**)(babl->fish_path.conversion),
&babl->fish_path.conversions,
temp_chain,
- 0,
+ 0,
max_path_length ());
if (babl->fish_path.conversions==0)
babl_free (babl);
return NULL;
}
-
- {
+
+ {
Babl *ret = babl_db_insert (babl_fish_db (), babl);
if (ret!=babl)
babl_free (babl);
void *bufA = NULL;
void *bufB = NULL;
int i;
-
+
babl_assert (source);
babl_assert (destination);
-
+
if (conversions > 1)
bufA = babl_malloc (n * sizeof (double) * 5);
if (conversions > 2)
bufB = babl_malloc (n * sizeof (double) * 5);
-
+
for (i=0; i<conversions; i++)
{
if (i==0 && conversions == 1)
{
double *test;
int i;
-
+
srandom (20050728);
test = babl_malloc (sizeof (double) * test_pixels * 4);
NULL);
double error = 0.0;
-
- double *test;
+
+ double *test;
void *source;
void *destination;
double *destination_rgba_double;
ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
-
- /* create sourcebuffer from testbuffer in the correct format */
+
+ /* create sourcebuffer from testbuffer in the correct format */
babl_process (fish_rgba_to_source,
test, source, test_pixels);
babl_assert (fish);
-
+
switch (fish->class_type)
{
case BABL_FISH_PATH:
-
+
fprintf (output_file, "<td class='cell'%s><a href='javascript:o()'>%s",
fish->fish.processings > 0 ? " style='background-color: #69f'":"",
utf8_bar[fish->fish_path.conversions]);
fprintf (output_file, "<h3><span class='g'>path</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
if (fish->fish.processings > 0)
{
- fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+ fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
}
if (fish->fish.processings > 0)
{
- fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+ fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
}
break;
}
}
-
+
fprintf (output_file, "<tr>");
fprintf (output_file, "<td class='format_name'><a href='javascript:o();'>%s", expanded_name);
{
fprintf (output_file, "<em>error:</em> %f <em>cost:</em> %4.0f <em>processings:</em> %i <em>pixels:</em> %li", error, cost,
babl->conversion.processings, babl->conversion.pixels);
fprintf (output_file, "</dd>");
-
+
return 0;
}
{
output_file = file;
- fprintf (output_file,
+ fprintf (output_file,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
"<html>\n"
if (babl->class_type >= BABL_CONVERSION &&
babl->class_type <= BABL_CONVERSION_PLANAR)
return babl_conversion_process (babl, source, destination, n);
-
+
if (babl->class_type == BABL_FISH ||
babl->class_type == BABL_FISH_REFERENCE ||
babl->class_type == BABL_FISH_PATH ||
ret = babl_fish_process (babl, source, destination, n);
ticks -= babl_ticks();
- ticks *= -1;
+ ticks *= -1L;
- babl->fish.msecs += ticks;
+ babl->fish.usecs += ticks;
babl->fish.processings++;
babl->fish.pixels += ret;
return ret;
{
void **ptr;
int len=0;
-
+
ptr = list;
while (NULL!=*ptr)
{
void *new)
{
int orig_len=0;
-
+
if (*list)
{
orig_len = list_length (*list);
}
- *list = babl_realloc ( (*list),
+ *list = babl_realloc ( (*list),
sizeof(void *) * (orig_len + 2));
if (!(*list))
static struct timeval start_time;
static struct timeval measure_time;
-#define msecs(time) ((time.tv_sec-start_time.tv_sec)*10000000 + time.tv_usec)
+#define usecs(time) ((time.tv_sec-start_time.tv_sec)*1000000 + time.tv_usec)
static void
init_ticks (void)
gettimeofday (&start_time, NULL);
}
-unsigned int
+long
babl_ticks (void)
{
init_ticks ();
gettimeofday (&measure_time, NULL);
- return msecs(measure_time) - msecs(start_time);
+ return usecs(measure_time) - usecs(start_time);
}
double
long samples)
{
double error = 0.0;
- int i;
+ long i;
for (i=0; i<samples; i++)
error += fabs (imgA[i] - imgB[i]);
BablEachFunction each_fun,
void *user_data);
-unsigned int babl_ticks (void);
+long
+babl_ticks (void);
double
babl_rel_avg_error (double *imgA,